 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>운세의 신</title>

	<link rel="stylesheet" type="text/css" href="/css/common.css">
	<link rel="stylesheet" type="text/css" href="/css/sub.css">
    <link rel="stylesheet" type="text/css" href="/css/bbs.css"/>
	
	<link href="/css/lib/myconfig.jquery.validate.css" rel="stylesheet" type="text/css"/>
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="/js/lib/jquery.validate.min.js" type="text/javascript"></script>
	
	<script type="text/javascript">
		
		$(document).ready(function() {
			
			// 댓글 메세지
			var reply_msg = "욕설, 비방등 게시물의 성격과 맞지 않는 글은 관리자에 의해 삭제될 수 있습니다.";
			$("#comment").val(reply_msg);
			$("#comment").bind({
				focus: function() {
					if( $(this).val() == reply_msg ) {
						$(this).val('');
					}
				},
				blur: function() {
					if( $(this).val() == '') {
						$(this).val(reply_msg);
					}
				}
			});
			
			// 공감하기 버튼 눌렀을때
			$('#btn_recommend').click(function() {
				
				var idx = $('#idx').val();
				
				var action_url = "/bbs/postscript/recommend_ok";
				
				$.get(action_url,{'idx':idx},
					
					function(result) {
						// 공감 성공시 공감갯수를 가져오고 실패시 에러 메세지를 가져온다.
						if (isNaN(parseInt(result, 10))) {
							alert(result);
						} else {
							$('#recommend').html("("+result+")");
						}
					}
				);
			});
			
			// 삭제 버튼 눌렀을때
			$('#btn_remove').click(function() {
				if (confirm('정말 삭제하시겠습니까?')) {
					location.href = "<?=$remove_url?>";
				}
			});
			
			// validate signup form on keyup and submit
			$("#frm").validate({
				rules: {
					comment: "required"
				},
				messages: {
					comment: "덧글을 입력해 주세요."
				},
				submitHandler: function(form) {
					var comment = $("#comment").val();
					if (comment == '' || comment == reply_msg) {
						alert('덧글을 입력하세요.');
						$("#comment").focus();
					} else {
						form.submit();
					}
				}
			});
		});

		// 덧글 삭제 버튼 눌렀을때
		function remove_reply(idx,seq) {
			if (confirm('덧글을 정말 삭제하시겠습니까?')) {
				location.href = "/bbs/<?=$cate?>/remove_reply_ok?idx="+idx+"&seq="+seq;
			}
		}
		
<?	if ($sess_userinfo['login_yn'] == 'Y') : ?>
		function result() {
			$("#frm_starbirth").submit();
		}

		function gunghap() {
			$("#frm_gunghap").submit();
		}
<?	else : ?>
		function result() {
			alert('회원가입 후 이용가능합니다.');
			location.href = '/member/join';
		}

		function gunghap() {
			alert('회원가입 후 이용가능합니다.');
			location.href = '/member/join';
		}
<?	endif ?>
	</script>

</head>
<body>

<div id="wrap">
	<!-- Header -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/main_header.php'; ?>
	<!--// Header -->

	<!--커튼 데코레이션-->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/drape.php'; ?>
	<!--//커튼 데코레이션-->
    
    <!--컨텐츠-->
	<div id="content">
		<!--휘장-->
		<div class="keybox1"> </div>
		<!--//휘장-->
		
		<p class="key_visual"><img src="/images/sub/bbs/bbs_visual.png" alt="운세게시판" /></p>

		<!--왼쪽 컨텐츠-->
		<div class="assistant">
			<!--왼쪽 메뉴-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/inc_lnb.php'; ?>
			<!--// 왼쪽 메뉴-->

			<!--추천테마-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/theme2.php'; ?>
			<!--//추천테마-->

			<!--회원가입-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/member_join.php'; ?>
			<!--//회원가입-->

			<!--고객센터-->
			<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/static/cs.php'; ?>
			<!--//고객센터_추가-->
		</div>
		<!--//왼쪽 컨텐츠-->

		<!-- 메인컨텐츠-->
		<div class="cont">
			<!--리스트-->
			<div class="bbs">
				<h3><?=$category_title?></h3>
				
				<div class="read">
				
					<div class="readTit">
						<div class="tit">
							<dl>
								<dt><?=$content['subject']?><span class="user_name"><?=$content['nickname']?></span></dt>
								<dd><?=substr($content['create_dt'], 0,10)?></dd>
								<dd><span>조회</span><?=$content['hit']?></dd>
							</dl>
						</div>
						<div class="vote">
							<dl>
								<dt class="voteOk">
									<?	if ($content['user_id'] != $sess_userinfo['user_id']) : ?>
										<a href="javascript:;" id="btn_recommend"><img src="/images/common/board/bt_like.png" alt="공감하기" /></a><span id="recommend">(<?=$content['recommend']?>)</span>
									<?	else : ?>
										<a href="javascript:;" onclick="alert('본인의 글은 공감할 수 없습니다.')"><img src="/images/common/board/bt_like.png" alt="공감하기" /></a><span id="recommend">(<?=$content['recommend']?>)</span>
									<?	endif ?>
								</dt>
							</dl>
						</div>
					</div>					
					<div class="readContents">
						<form name="frm_starbirth" id="frm_starbirth" method="post" action="/unse/star/todaybirth/result">
							<input type="hidden" name="target_yyyy" value="<?=date("Y",time());?>"  />
							<input type="hidden" name="idx" value="<?=$artist['idx']?>" />
							<input type="hidden" name="user_name" value="<?=$artist['artist_name']?>" />
							<input type="hidden" name="sex" value="<?=$artist['sex']?>" />
							<input type="hidden" name="birth_yyyy" value="<?=$artist['birth_yyyy']?>" />
							<input type="hidden" name="birth_mm" value="<?=$artist['birth_mm']?>" />
							<input type="hidden" name="birth_dd" value="<?=$artist['birth_dd']?>" />
							<input type="hidden" name="birth_hh" value="0" />
							<input type="hidden" name="birth_solunar" value="S_C" />
						</form>
						<form name="frm_gunghap" id="frm_gunghap" method="post" action="/unse/star/gunghap/form">
							<input type="hidden" name="artist_idx" value="<?=$artist['idx']?>" />
							<input type="hidden" name="your_name" value="<?=$artist['artist_name']?>" />
							<input type="hidden" name="your_sex" value="<?=$artist['sex']?>" />
							<input type="hidden" name="your_birth_yyyy" value="<?=$artist['birth_yyyy']?>" />
							<input type="hidden" name="your_birth_mm" value="<?=$artist['birth_mm']?>" />
							<input type="hidden" name="your_birth_dd" value="<?=$artist['birth_dd']?>" />
						</form>
						
						<div align="center">
	                		<!--스타버튼바로가기영역-->
	                		<div class="star_bt">
	                        	<input type="image" onclick="result()" src="/images/common/bt_todaystar.png" alt="오늘의 운세" />
	                            <input type="image" onclick="gunghap()" src="/images/common/bt_togetherstar.png" alt="스타와의 궁합" />
	                        </div>
	                        <!--//스타버튼바로가기영역-->
							
							<br/>
<?	for ($i=1; $i < count($content['file']); $i++) : ?> 
<?		$file_item = $content['file'][$i];  ?>
							<img src="<?=$file_item['file_url'].$file_item['file_name']?>" /><br/><br/>
<?	endfor ?>
							<br/>
	                		<!--스타버튼바로가기영역-->
	                		<div class="star_bt">
	                        	<input type="image" onclick="result()" src="/images/common/bt_todaystar.png" alt="오늘의 운세" />
	                            <input type="image" onclick="gunghap()" src="/images/common/bt_togetherstar.png" alt="스타와의 궁합" />
	                        </div>
	                        <!--//스타버튼바로가기영역-->
	
							<br/>
							<br/>
							<span><?=str_replace("\n", "<br/>", $content['content'])?></span>
							<br/>
							<a href="/product/package"><img src="/images/banner/vip_result_w730.jpg" alt="VIP회원권 배너" /></a>
						</div>
					</div>

					<!--이전글보기-->
					<div class="readPrev">
						<?	if(!empty($prev_content)) : ?>
						<table width="100%" summary="이전글한줄보기" cellpadding="0" cellspacing="0">
							<caption class="blind">이전글한줄보기</caption>
							<colgroup>
								<col width="13%" />
								<col width="*" />
								<col width="15%" />
								<col width="10%" />
								
								<col width="15%" />
							</colgroup>
							<tbody>
								<tr>
									<td class="signPrev"><img src="/images/common/bullet3.png" alt="이전글블릿" />이전글</td>
									<td class="tle"><a href="<?=$read_url.$prev_content['idx']?>"><?=$prev_content['subject']?><span class="reply">(<?=$prev_content['reply_cnt']?>)</span></a></td>
									<td class="writer"><?=$prev_content['nickname']?></td>
									<td class="vote2"><img src="/images/common/board/icon_heart2.png" alt="공감" /><?=$prev_content['recommend']?></td>
									<td class="hit"><?=$prev_content['hit']?></td>
							   </tr>
							</tbody>
						</table>
						<?	endif ?>
					</div>
					<!--//이전글보기-->
					<!--다음글보기-->
					<div class="readNext">
						<?	if(!empty($next_content)) : ?>
						<table width="100%" summary="다음글한줄보기" cellpadding="0" cellspacing="0">
							<caption class="blind">다음글한줄보기</caption>
							<colgroup>
								<col width="13%" />
								<col width="*" />
								<col width="15%" />
								<col width="10%" />
								<col width="15%" />
							</colgroup>
							<tbody>
								<tr>
									<td class="signNext"><img src="/images/common/bullet4.png" alt="다음글블릿" />다음글</td>
									<td class="tle"><a href="<?=$read_url.$next_content['idx']?>"><?=$next_content['subject']?><span class="reply">(<?=$next_content['reply_cnt']?>)</span></a></td>
									<td class="writer"><?=$next_content['nickname']?></td>
									<td class="vote2"><img src="/images/common/board/icon_heart2.png" alt="공감" /><?=$next_content['recommend']?></td>
									<td class="hit"><?=$next_content['hit']?></td>
								</tr>
							</tbody>
						</table>
						<?	endif ?>
					</div>
					<!--//다음글보기-->
					
					<div class="boardbt_area">
						<?	if ($content['user_id'] == $sess_userinfo['user_id']) : ?>
							<a href="<?=$modify_url?>"><img src="/images/common/board/bt_modify.png" alt="수정" /></a>
							<a href="javascript:;" id="btn_remove"><img src="/images/common/board/bt_del.png" alt="삭제" /></a>
						<?	endif ?>
						<a href="<?=$list_url?>"><img src="/images/common/board/bt_list.png" alt="목록" /></a>
					</div>
					
					<!--덧글영역-->
					<div class="comment">
						<dl class="num">
							<h4 class="blind">덧글</h4>
							<dt>덧글의견<span>(<?=count($reply_list)?>)</span></dt>
						</dl>
						<div class="commentList">
							<?	foreach ($reply_list as $item) : ?>
							<dl>
								<dt class="user_name"><?=$item['nickname']?><span><?=$item['create_dt']?></span></dt>
								<dd>
									<?=str_replace("\n", "<br/>", $item['content'])?>
									<?	if($item['user_id'] == $sess_userinfo['user_id']) : ?>
										<a href="javascript:;" onclick="remove_reply('<?=$item['idx']?>','<?=$item['seq']?>')">[삭제]</a>
									<?	endif ?>
								</dd>
							</dl>
							<?	endforeach ?>
						</div>
						<div class="commentWrite">
							<form name="frm" id="frm" method="post" action="<?=$action_url?>">
								<input type="hidden" name="idx" id="idx" value="<?=$content['idx']?>" />
						   		<dl>
									<dt class="user_name" ><?=$sess_userinfo['nickname'];?></dt>
									<dt ><textarea name="content" id="comment">욕설, 비방등 게시물의 성격과 맞지 않는 글은 관리자에 의해 삭제될 수 있습니다. </textarea></dt>
									<dd><input type="image" src="/images/common/board/bt_write.png" alt="글쓰기" /></dd>
								</dl>
							</form>
						</div>
					</div>
					<!--//덧글영역-->
				</div>
				<!--게시글보기--> 
			</div>
			<!--//리스트-->
		</div>
		<!--// 메인컨텐츠-->
	</div>
	<!--컨텐츠-->
	
	

	<!-- Footer -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/main_footer.php'; ?>
	<!--// Footer -->
</div>
</body>
</html>